define(['jquery'],function($){

  var Run=function(){

      function img(){
        var $t=$('.middle').scrollLeft();
        var $middle=$('.middle');

        setInterval(function(){
          $t++;
          $middle.scrollLeft($t);
          var $w=$middle.width();
          if($middle.scrollLeft()>=$w){
            $t=0;
          }
        },10);

      }


      var xhr=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
          xhr.open('GET','../../json/index.json','true');
          xhr.send();
          xhr.onreadystatechange=function(){
            if(xhr.readyState==4&&xhr.status==200){
                var datas=JSON.parse(xhr.responseText);
                    pic(datas);
                    fruit();
                    img();
            }
          }

      function pic(data){
          var json={
            "item":data
          }
            // console.log(json);
        var all=document.querySelector('#all');
        var bt=baidu.template;
        var html=bt('template1',json);
            all.innerHTML=html;
      }

      function fruit(){
          var $fruit=$('.fruit-buttom');
          var $lastFruit=$fruit.eq($fruit.length-1);
          // console.log($lastFruit);
          $lastFruit.css('border-bottom','60px solid #ccc');
      }

  };

    return {
        run:Run
    };


})
